
<div style="margin:50px 50px 50px 50px">
    <form class="layui-form layui-form-pane" lay-filter="optionInfo">
        <div class="layui-form-item">

            <label class="layui-form-label"><i class="ui blue book icon"></i>项目编号</label>
            <div class="layui-input-block">
                <input type="text" name="projectId" required lay-verify="required" autocomplete="off"
                       placeholder="请输入项目名称" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><i class="ui violet user outline icon"></i>提出人</label>
            <div class="layui-input-block">
                <input type="text" name="staffId" required lay-verify="exits" class="layui-input">
                <input type="hidden" name="optionId" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><i class="ui violet user outline icon"></i>意见内容</label>
            <div class="layui-input-block">
                <textarea name="content" required lay-verify="required" class="layui-textarea"></textarea>
            </div>
        </div>

        <div class="layui-form-item" style="margin-left: -110px">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="add">添加</button>
                <button type="reset" class="layui-btn layui-btn-danger">重置</button>
            </div>
        </div>
    </form>
</div>
<script>

    layui.use(['form', 'layedit', 'laydate'], function () {
        const form = layui.form
            , layer = layui.layer
        form.on('submit(add)', function (data) {
            $.ajax({
                url: "/option/add",
                method: "post",
                contentType: "application/json;charset=utf-8",
                data: JSON.stringify(data.field),
                dataType: "json",
                success: function (res) {
                    if (res.msg === 'FAIL') {
                        layer.alert(res.result, {
                            icon: 2,
                            skin: 'layer-ext-moon'
                        })
                    } else {
                        layer.alert('修改成功', {
                            icon: 1,
                            skin: 'layer-ext-moon'
                        })
                    }
                }
            })
            return false;
        });
    });
</script>